class Solution {
    //定义返回值
    List<List<Integer>> re = new ArrayList<>();
    List<Integer> list = new ArrayList<>();
    public List<List<Integer>> fourSum(int[] nums, int target) {
        if(nums.length < 4 || nums == null){
            return re;
        }
        //数组排序
        Arrays.sort(nums);
        clo(4,0,target,nums);
        return re;
    }
    //定义 个数，开始值，目标值，数组
    public void clo(int k , int begin ,int target ,int[] nums){
        int len = nums.length;
        if( k > 2 ){
            //从数组中取数放入clo方法中，会改变 k , start ,target的值
            for(int i = begin ; i < len-2 ;i++){
                if( i > begin && nums[i] == nums[i-1]) continue;
                
                list.add(nums[i]);
                clo(k-1,i+1,target-nums[i],nums);
                //回溯
                list.remove(list.size()-1);
            }
        }else if(k==2){
            int right = len - 1;
            int left = begin ;
            while(left < right ){
                // if(list.length == 4)
                int add = nums[right] + nums[left];
                if( add == target ){
                    list.add(nums[left]);
                    list.add(nums[right]);
                    re.add(new ArrayList<Integer>(list));
                    list.remove(list.size()-1);
                    list.remove(list.size()-1);
                    //继续寻找,当左右的后面一个与现在的值相等的时候，跳过这个元素；因为不允许重复
                    while (left < right && nums[left] == nums[left+1]) left++;
                    while (left < right && nums[right] == nums[right-1]) right--;
                    //没有重复，两边同时移动；
                    right--;
                    left++;

                }else if( add < target){
                    do{
                        left++;
                    }while( left < right && nums[left] == nums[left-1]);
                }else if( add > target){
                    do{
                        right--;
                    }while( left < right && nums[right] == nums[right+1]);
                }
            }
        }
    }
}

public class MainClass {
    public static int[] stringToIntegerArray(String input) {
        input = input.trim();
        input = input.substring(1, input.length() - 1);
        if (input.length() == 0) {
          return new int[0];
        }
    
        String[] parts = input.split(",");
        int[] output = new int[parts.length];
        for(int index = 0; index < parts.length; index++) {
            String part = parts[index].trim();
            output[index] = Integer.parseInt(part);
        }
        return output;
    }
    
    public static String integerArrayListToString(List<Integer> nums, int length) {
        if (length == 0) {
            return "[]";
        }
    
        String result = "";
        for(int index = 0; index < length; index++) {
            Integer number = nums.get(index);
            result += Integer.toString(number) + ", ";
        }
        return "[" + result.substring(0, result.length() - 2) + "]";
    }
    
    public static String integerArrayListToString(List<Integer> nums) {
        return integerArrayListToString(nums, nums.size());
    }
    
    public static String int2dListToString(List<List<Integer>> nums) {
        StringBuilder sb = new StringBuilder("[");
        for (List<Integer> list: nums) {
            sb.append(integerArrayListToString(list));
            sb.append(",");
        }
    
        sb.setCharAt(sb.length() - 1, ']');
        return sb.toString();
    }
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            int[] nums = stringToIntegerArray(line);
            line = in.readLine();
            int target = Integer.parseInt(line);
            
            List<List<Integer>> ret = new Solution().fourSum(nums, target);
            
            String out = int2dListToString(ret);
            
            System.out.print(out);
        }
    }
}